Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add StreamModules to ConsoleService #2931

Merged
merged 9 commits into from
Oct 3, 2024
Merged

feat: add StreamModules to ConsoleService #2931

merged 9 commits into from
Oct 3, 2024

Conversation

deniseli
Copy link
Contributor

@deniseli deniseli commented Oct 1, 2024

Part 1 of #2805

Next:

  1. Client side integration for this PR's version of StreamModules, which behaves in a way that's very similar to the existing get endpoint
  2. Address the TODO in StreamModules: detect + push deployment updates to the stream
  3. Handle streaming updates on the client side

@deniseli deniseli requested review from a team and alecthomas as code owners October 1, 2024 19:55
@deniseli deniseli requested review from a team and wesbillman and removed request for a team October 1, 2024 19:55
This was referenced Oct 1, 2024
configs = append(configs, &pbconsole.Config{
Config: c,
})
configs = append(configs, configFromDecl(decl))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is much nicer here :)

Comment on lines 236 to 238
config := decl.ToProto().(*schemapb.Config)
return &pbconsole.Config{
Config: config,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uber nit/question, can we just use decl.ToProto().(*schemapb.Config) directly here and in the similar places below?

return &pbconsole.Config{
	Config: decl.ToProto().(*schemapb.Config),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea - done! and the linter didn't even complain :)

return module, nil
}

func moduleFromDecls(decls []schema.Decl, sch *schema.Schema) (*pbconsole.Module, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some tests (can be in another PR) for some of this stuff? Or is it covered by other tests atm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I only added an integration test for now and didn't test for the contents of the various <blahblah>FromDecl methods since we're going to change so much of that anyway.

Comment on lines +139 to +155
repeated Database databases = 9;
repeated Enum enums = 10;
repeated FSM fsms = 11;
repeated Topic topics = 12;
repeated TypeAlias typealiases = 13;
repeated Subscription subscriptions = 14;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

import type { Module } from '../../protos/xyz/block/ftl/v1/console/console_pb'

const streamModulesKey = 'streamModules'
const updateIntervalMs = 60 * 1000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass this in and default it? Also, is this the correct number of nano seconds (I might have had this wrong before too 😂)?

Math, mostly for me...
1 nano = 1,000,000 milliseconds

60 * 1000 * 1000 = 60,000,000

So I think this is updating at 60ms which might be faster than we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof thanks for catching that nano issue!

In retrospect, I'm going to just remove this and leave it totally controlled by the server side. It seems like something we'll be able to optimize a lot more cleanly without having to also conform to potentially several distinct client-side refresh thresholds...

} catch (error) {
if (error instanceof ConnectError) {
if (error.code !== Code.Canceled) {
console.error('Console service - streamEvents - Connect error:', error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streamEvents -> streamModules

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoopsie!

@deniseli deniseli enabled auto-merge (squash) October 3, 2024 16:39
@deniseli deniseli merged commit dcd3dc7 into main Oct 3, 2024
94 checks passed
@deniseli deniseli deleted the dli/se branch October 3, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants